<?php
namespace Admin\Controller;
use Think\Cache;
use Think\Controller;

class IndexController extends CommonController {

    const User = null;
    /**
     * index 控制器前置方法
     */
    public function _before_index()
    {
        //$this->User = D('User');//或者 new UserModel();
        //$this->Movies = D('Movies');
        S(array('type'=>'xcache','expire'=>60));
    }

    /**
     * 默认方法
     * @author mmy
     */
    public function index()
    {
        $res = $this->checkLogin();
        //检查等录与否，没登录跳登录页面
        if(!$res)
        {
            redirect('admin.php?c=login&a=index');
        }
        //拿出导航
        $this->getMenuList($this->_data,0,0);
        //获取管理员列表并分页
        $page = (int)($_GET['page'])? (int)($_GET['page']):'1';
        $limit = 1;
        $total = $this->User->getAdminTotal();

        if($total>0)
        {
            $url = "/admin.php?c=index&a=index";
            $this->_data['adminList'] = $this->User->getUserList($page,$limit);
            $this->_data['pagebar'] = $this->pagebarht ( $url, array(), $limit, $page, $total );
        }

        $this->assign('data',$this->_data);
        $this->display('index');
    }

    /**
     * 测试方法
     */
    public function test()
    {
        $memCache = Cache::getInstance();
      //  $memCache->setOptions('expire',3600);
        $res = $memCache->connect('172.20.17.108', 11211);
        var_dump($res);exit;
//        var_dump($res);exit;
//      //  var_dump('mmy_name');
    }

    /**
     * 测试方法1
     */
    public function test1()
    {
      //  session(array('mmy_name'=>'123456','expire'=>30));
        echo '<pre>';
        echo '111';
        var_dump(session());
    }

}